<?php

require_once(dirname(__FILE__)."/../core/safeParam.php");

require_once('../includes/config.php');
switch ($function) {
  case "contact":
    require_once 'libmail.php';
    //This command imports the values from contact.php. Please do not touch.
    @import_request_variables("gpc");
    $server = $_SERVER['HTTP_HOST'];
    // find admin email
    require_once('../core/database.php');
    $editsequence = $edit;
    $query = $database->query("SELECT * FROM config ");
    while ($list = mysql_fetch_array($query)) {
      $adminemail = $list['email'];
      $email1     = $list['email1'];
      $email2     = $list['email2'];
      $email3     = $list['email3'];
      $email4     = $list['email4'];
      $email5     = $list['email5'];
      $email6     = $list['email6'];
    } //$list = mysql_fetch_array($query)
    if ($location == '1') {
      $locationemail = $email1;
    } //$location == '1'
    elseif ($location == '2') {
      $locationemail = $email2;
    } //$location == '2'
      elseif ($location == '3') {
      $locationemail = $email3;
    } //$location == '3'
      elseif ($location == '4') {
      $locationemail = $email4;
    } //$location == '4'
      elseif ($location == '5') {
      $locationemail = $email5;
    } //$location == '5'
      elseif ($location == '6') {
      $locationemail = $email6;
    } //$location == '6'
    // start pragma
    $sendmessage = '
New Message from  ' . $server . ' Contact Page<br>
  First Name: ' . $fname . '<br>
  Last Name: ' . $lname . '<br>
  Address: ' . $address . '<br>
  City: ' . $city . '<br>
  State: ' . $state . '<br>
  Zip Code: ' . $zipcode . ' <br>
  Day Phone: ' . $dayphone . '<br>
  Evening Phone: ' . $evephone . '<br>
  email: ' . $email . '<br>
  How did you hear about us: ' . $hearaboutus . '<br>
  Other: ' . $other . '<br>
   Message: ' . $message . '';
    $m           = new Mail(); // create the mail
    $m->From($email);
    $m->To($locationemail);
    $m->CC($adminemail);
    $m->Subject('New Message from  ' . $server . ' Contact Page');
    $m->Body($sendmessage);
    $m->Priority(4);
    $m->Send(); // send the mail 
    echo '<h1>Processing request......</h1>';
    echo '<script language="JavaScript">

	window.location="../index.php?id=28&email=thankyou";

</script>';
    break;
  case "directions":
    $address = $_POST['address'];
    $city    = $_POST['city'];
    $state   = $_POST['state'];
    echo '<script language="JavaScript">

window.location="http://maps.google.com/maps?f=d&hl=en&saddr=' . $address . ',+' . $city . '+' . $state . '&daddr=' . $company['address'] . ',+' . $company['city'] . ',+' . $company['state'] . '&om=1";

</script>';
    break;
  case "directions-map":
    $tddress  = $_POST['taddress'];
    $faddress = $_POST['faddress'];
    echo '<script language="JavaScript">

window.location="http://maps.google.com/maps?f=d&hl=en&saddr=' . $tddress . '&daddr=' . $faddress . '&om=1";

</script>';
    break;
} //$function
?>
